package oc.tm.sg.core.test.proxy.bp;

import java.util.Arrays;

import org.neuroph.core.data.DataSet;
import org.neuroph.core.data.DataSetRow;
import org.neuroph.core.learning.LearningRule;
import org.neuroph.nnet.Hopfield;

public class Nnet {

	class ILearningRule extends LearningRule {

		private static final long serialVersionUID = 1L;

		public void learn(DataSet trainingSet) {

		}

	}

	public static void main(String[] args) {
		DataSet trainingSet = new DataSet(9);
		trainingSet.addRow(new DataSetRow(new double[] { 1, 0, 1, 1, 1, 1, 1,0, 1 })); // H letter
		trainingSet.addRow(new DataSetRow(new double[] { 1, 1, 1, 0, 1, 0, 0,1, 0 })); // T letter

		// create hopfield network
		Hopfield myHopfield = new Hopfield(9);
		// learn the training set
		myHopfield.learn(trainingSet);

		// test hopfield network
		System.out.println("Testing network");
		// add one more 'incomplete' H pattern for testing - it will be recognized as H
		trainingSet.addRow(new DataSetRow(new double[] { 1, 0, 0, 1, 0, 1, 1,0, 1 }));

		// print network output for the each element from the specified training
		// set.
		for (DataSetRow trainingSetRow : trainingSet.getRows()) {
			myHopfield.setInput(trainingSetRow.getInput());
			myHopfield.calculate();
			myHopfield.calculate();
			double[] networkOutput = myHopfield.getOutput();

			System.out.print("Input: " + Arrays.toString(trainingSetRow.getInput()));
			System.out.println(" Output: " + Arrays.toString(networkOutput));
		}
	}

}
